﻿using System;
using System.Collections.Generic;
using System.Text;
using NTL.DAL;

namespace NTL.BLL.Galleries
{
	public class Image : BizObject
	{
		private long _galleryId;
		private long _imageId;
		private DateTime _addedDate;
		private DateTime _timeline;
		private string _name;
		private string _url;
		private bool _visible;

		public long GalleryId { get { return _galleryId; } set { _galleryId = value; } }
		public long ImageId { get { return _imageId; } set { _imageId = value; } }
		public DateTime AddedDate { get { return _addedDate; } set { _addedDate = value; } }
		public DateTime Timeline { get { return _timeline; } set { _timeline = value; } }
		public string Name { get { return _name; } set { _name = value; } }
		public string Url { get { return _url; } set { _url = value; } }
		public bool Visible { get { return _visible; } set { _visible = value; } }

		public Image(long galleryId, long id, DateTime addedDate, DateTime timeline, string name, string url, bool visible)
		{
			_galleryId = galleryId;
			_imageId = id;
			_addedDate = addedDate;
			_timeline = timeline;
			_name = name;
			_url = url;
			_visible = visible;
		}

		/***********
		 * PRIVATE *
		 ***********/
		private static Image GetFromDetails(ImageDetails record)
		{
			if (record == null) return null;
			return new Image(record.GalleryId, record.ImageId,
				record.AddedDate, record.Timeline, record.Name, record.Url, record.Visible);
		}
		private static List<Image> GetListFromDetailsList(List<ImageDetails> recordset)
		{
			List<Image> images = new List<Image>();
			foreach (ImageDetails record in recordset)
				images.Add(GetFromDetails(record));
			return images;
		}
	}
}
